package com.javarush.test.level14.lesson08.bonus01;

import java.io.FileInputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;

/* Нашествие эксепшенов
Заполни массив exceptions 10 различными эксепшенами.
Первое исключение уже реализовано в методе initExceptions.
*/

public class Solution
{
    public static List<Exception> exceptions = new ArrayList<Exception>();

    public static void main(String[] args)
    {
        initExceptions();

        for (Exception exception : exceptions)
        {
            System.out.println(exception);
        }
    }

    private static void initExceptions()
    {   //it's first exception
        try
        {
            float i = 1 / 0;


        }
        catch (Exception e)
        {
            exceptions.add(e);
        }
        try
        {
            int[] arr = {5, 5, 7, 3, 9};
            for (int i = 0; i < 6; i++) arr[i] = (arr[i] + 1);


        }
        catch (Exception e)
        {
            exceptions.add(e);
        }
        try
        {
            String reader = "kbkh";
            int i = Integer.parseInt(reader);
        }
        catch (Exception e)
        {
            exceptions.add(e);
        }
        try
        {
            throw new NullPointerException();
        }
        catch (Exception e)
        {
            exceptions.add(e);
        }
        try
        {
            throw new RuntimeException();
        }
        catch (Exception e)
        {
            exceptions.add(e);
        }
        String siteUrl = "sssss";
        URL url;
        try
        {
            url = new URL(siteUrl);
        }
        catch (Exception e)
        {
            exceptions.add(e);
        }


        try
        {
            FileInputStream file = new FileInputStream("C:\1.bat");
            byte x = (byte) file.read();
        }
        catch (Exception e)
        {
            exceptions.add(e);
        }

        try
        {
            String str = "easysteps2buildwebsite";
            //System.out.println(str.length());;
            char c = str.charAt(0);
            c = str.charAt(40);
            //System.out.println(c);
        }
        catch (Exception e)
        {
            exceptions.add(e);
        }

        Stack s = new Stack();
        {
            try
            {
                s.pop();
            }
            catch (Exception e)
            {
                exceptions.add(e);
            }
        }
        Object szStr[] = new String[10];

        try
        {
            szStr[0] = new Character('*');
        }
        catch (Exception e)
        {
            exceptions.add(e);
        }



    }
}

